//microcommand define striped-flag
const render = require("@lnnbot-private/koishi-canvas-svg")
inject(["canvas"])
signature("<...css-colors>")
option("size", "-s <css-length>", { fallback: "200px", descPath: "commands.color.options.size" })
option("dir", "-d <css-angle>", { fallback: "180deg" })
action(({ session, options: { size, dir } }, ...input) => {
let n = input.length;
if (n <= 0) return session.text(".invalid");
let cssStr = "linear-gradient(" + dir;
for (let i = 0; i < n; i++) {
 cssStr = cssStr + ", " + input[i] + " " + (100.0 * i / n) + "%, " + input[i] + " " + (100.0 * (i + 1) / n) + "%";
}
cssStr = cssStr + ")";
return render(ctx.canvas, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: size.split(";")[0], height: size.split(";").at(-1) }, h("foreignObject", { x: "0", y: "0", width: "100%", height: "100%" }, h("div", { xmlns: "http://www.w3.org/1999/xhtml", style: "width:100%;height:100%;background:" + cssStr }))).toString())
})
locale("zh-CN", { description: "生成条形旗", options: { dir: "指定方向角度（默认 180deg）" }, messages: { invalid: "输入无效…" } })